package pe.com.bn.sach.dao.impl;
import java.util.List;
import com.ibatis.sqlmap.client.SqlMapClient;
import pe.com.bn.sach.dao.DestinoDAO;
import pe.com.bn.sach.domain.Bnchf18Destino;

public class DestinoImpl implements DestinoDAO {
 
	
	protected SqlMapClient sqlMap = null;
	
	public void setSqlMap(SqlMapClient sqlMap) {
		this.sqlMap = sqlMap;
	}

	public List listDestino() throws Exception{
		return sqlMap.queryForList("sqlDestino.listaDestino","");
	}

	public Bnchf18Destino encontrarDestino(Bnchf18Destino bnchf18Destino) throws Exception{
		Bnchf18Destino bnchf18Desti=new Bnchf18Destino();
		try {
			return (Bnchf18Destino)sqlMap.queryForList("sqlDestino.encontrarDestino",bnchf18Destino).get(0);	
		} catch (Exception e) {return bnchf18Desti;}
		 
	}
	
	public void GuardaDestino(Bnchf18Destino bnchf18Destino)throws Exception{
		try{
			sqlMap.startTransaction();
			sqlMap.insert("sqlDestino.GuardaDestino",bnchf18Destino);
			sqlMap.commitTransaction();
		}catch(Exception e){
			e.printStackTrace();
			throw e;
		}finally{
			sqlMap.endTransaction();
		}
	}
	
	
}
